/*
 * Copyright 2022 NXP
 * SPDX-License-Identifier: MIT
 */

#include "lvgl/lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"
#include "custom.h"


void setup_scr_Voltmeter(lv_ui *ui){

	//Write codes Voltmeter
	ui->Voltmeter = lv_obj_create(NULL, NULL);

	//Write codes Voltmeter_chart_1
	ui->Voltmeter_chart_1 = lv_chart_create(ui->Voltmeter, NULL);

	//Write style LV_CHART_PART_BG for Voltmeter_chart_1
	static lv_style_t style_Voltmeter_chart_1_bg;
	lv_style_reset(&style_Voltmeter_chart_1_bg);

	//Write style state: LV_STATE_DEFAULT for style_Voltmeter_chart_1_bg
	lv_style_set_bg_color(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, 255);
	lv_style_set_pad_left(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, 5);
	lv_style_set_pad_right(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, 5);
	lv_style_set_pad_top(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, 5);
	lv_style_set_pad_bottom(&style_Voltmeter_chart_1_bg, LV_STATE_DEFAULT, 5);
	lv_obj_add_style(ui->Voltmeter_chart_1, LV_CHART_PART_BG, &style_Voltmeter_chart_1_bg);

	//Write style LV_CHART_PART_SERIES_BG for Voltmeter_chart_1
	static lv_style_t style_Voltmeter_chart_1_series_bg;
	lv_style_reset(&style_Voltmeter_chart_1_series_bg);

	//Write style state: LV_STATE_DEFAULT for style_Voltmeter_chart_1_series_bg
	lv_style_set_line_color(&style_Voltmeter_chart_1_series_bg, LV_STATE_DEFAULT, lv_color_make(0xe8, 0xe8, 0xe8));
	lv_style_set_line_width(&style_Voltmeter_chart_1_series_bg, LV_STATE_DEFAULT, 2);
	lv_style_set_line_opa(&style_Voltmeter_chart_1_series_bg, LV_STATE_DEFAULT, 255);
	lv_obj_add_style(ui->Voltmeter_chart_1, LV_CHART_PART_SERIES_BG, &style_Voltmeter_chart_1_series_bg);
	lv_obj_set_pos(ui->Voltmeter_chart_1, 1, 160);
	lv_obj_set_size(ui->Voltmeter_chart_1, 240, 160);
	lv_chart_set_type(ui->Voltmeter_chart_1,LV_CHART_TYPE_LINE);
	lv_chart_set_range(ui->Voltmeter_chart_1,0,100);
	lv_chart_set_div_line_count(ui->Voltmeter_chart_1, 3, 5);

	//Write codes Voltmeter_gauge_1
	ui->Voltmeter_gauge_1 = lv_gauge_create(ui->Voltmeter, NULL);

	//Write style LV_GAUGE_PART_MAIN for Voltmeter_gauge_1
	static lv_style_t style_Voltmeter_gauge_1_main;
	lv_style_reset(&style_Voltmeter_gauge_1_main);

	//Write style state: LV_STATE_DEFAULT for style_Voltmeter_gauge_1_main
	lv_style_set_bg_color(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 255);
	lv_style_set_text_color(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, lv_color_make(0x39, 0x3c, 0x41));
	lv_style_set_text_font(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, &lv_font_simsun_12);
	lv_style_set_text_letter_space(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_inner(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 15);
	lv_style_set_line_color(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, lv_color_make(0x8b, 0x89, 0x8b));
	lv_style_set_line_width(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 3);
	lv_style_set_line_opa(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 255);
	lv_style_set_scale_grad_color(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, lv_color_make(0x8b, 0x89, 0x8b));
	lv_style_set_scale_end_color(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, lv_color_make(0x00, 0xa1, 0xb5));
	lv_style_set_scale_width(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 9);
	lv_style_set_scale_border_width(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_scale_end_border_width(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 5);
	lv_style_set_scale_end_line_width(&style_Voltmeter_gauge_1_main, LV_STATE_DEFAULT, 4);
	lv_obj_add_style(ui->Voltmeter_gauge_1, LV_GAUGE_PART_MAIN, &style_Voltmeter_gauge_1_main);

	//Write style LV_GAUGE_PART_MAJOR for Voltmeter_gauge_1
	static lv_style_t style_Voltmeter_gauge_1_major;
	lv_style_reset(&style_Voltmeter_gauge_1_major);

	//Write style state: LV_STATE_DEFAULT for style_Voltmeter_gauge_1_major
	lv_style_set_line_color(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, lv_color_make(0x8b, 0x89, 0x8b));
	lv_style_set_line_width(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, 5);
	lv_style_set_line_opa(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, 255);
	lv_style_set_scale_grad_color(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, lv_color_make(0x8b, 0x89, 0x8b));
	lv_style_set_scale_end_color(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, lv_color_make(0x00, 0xa1, 0xb5));
	lv_style_set_scale_width(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, 16);
	lv_style_set_scale_end_line_width(&style_Voltmeter_gauge_1_major, LV_STATE_DEFAULT, 5);
	lv_obj_add_style(ui->Voltmeter_gauge_1, LV_GAUGE_PART_MAJOR, &style_Voltmeter_gauge_1_major);

	//Write style LV_GAUGE_PART_NEEDLE for Voltmeter_gauge_1
	static lv_style_t style_Voltmeter_gauge_1_needle;
	lv_style_reset(&style_Voltmeter_gauge_1_needle);

	//Write style state: LV_STATE_DEFAULT for style_Voltmeter_gauge_1_needle
	lv_style_set_size(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, 21);
	lv_style_set_bg_color(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, lv_color_make(0x41, 0x48, 0x5a));
	lv_style_set_bg_grad_color(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, lv_color_make(0x41, 0x48, 0x5a));
	lv_style_set_bg_grad_dir(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, 255);
	lv_style_set_pad_inner(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, 0);
	lv_style_set_line_width(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, 4);
	lv_style_set_line_opa(&style_Voltmeter_gauge_1_needle, LV_STATE_DEFAULT, 255);
	lv_obj_add_style(ui->Voltmeter_gauge_1, LV_GAUGE_PART_NEEDLE, &style_Voltmeter_gauge_1_needle);
	lv_obj_set_pos(ui->Voltmeter_gauge_1, 40, 0);
	lv_obj_set_size(ui->Voltmeter_gauge_1, 160, 160);
	lv_gauge_set_scale(ui->Voltmeter_gauge_1, 300, 37, 19);
	lv_gauge_set_range(ui->Voltmeter_gauge_1, 0, 180);
	static lv_color_t needle_colors_Voltmeter_gauge_1[1];
	needle_colors_Voltmeter_gauge_1[0] = lv_color_make(0xff, 0x00, 0x00);
	lv_gauge_set_needle_count(ui->Voltmeter_gauge_1, 1, needle_colors_Voltmeter_gauge_1);
	lv_gauge_set_critical_value(ui->Voltmeter_gauge_1, 120);
	lv_gauge_set_value(ui->Voltmeter_gauge_1, 0, 0);
	lv_anim_path_t lv_anim_path_Voltmeter_btn_1 = {.cb = lv_anim_path_linear};

	//Write codes Voltmeter_btn_1
	ui->Voltmeter_btn_1 = lv_btn_create(ui->Voltmeter, NULL);

	//Write style LV_BTN_PART_MAIN for Voltmeter_btn_1
	static lv_style_t style_Voltmeter_btn_1_main;
	lv_style_reset(&style_Voltmeter_btn_1_main);

	//Write style state: LV_STATE_DEFAULT for style_Voltmeter_btn_1_main
	lv_style_set_radius(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, 50);
	lv_style_set_bg_color(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, 150);
	lv_style_set_border_color(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_border_width(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, 2);
	lv_style_set_border_opa(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, 100);
	lv_style_set_outline_color(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_outline_opa(&style_Voltmeter_btn_1_main, LV_STATE_DEFAULT, 50);
	lv_obj_add_style(ui->Voltmeter_btn_1, LV_BTN_PART_MAIN, &style_Voltmeter_btn_1_main);
	lv_obj_set_pos(ui->Voltmeter_btn_1, 95, 320);
	lv_obj_set_size(ui->Voltmeter_btn_1, 50, 50);

	//Write animation: Voltmeter_btn_1move in y direction
	lv_anim_t Voltmeter_btn_1_y;
	lv_anim_init(&Voltmeter_btn_1_y);
	lv_anim_set_var(&Voltmeter_btn_1_y, ui->Voltmeter_btn_1);
	lv_anim_set_time(&Voltmeter_btn_1_y, 300);
	lv_anim_set_exec_cb(&Voltmeter_btn_1_y, (lv_anim_exec_xcb_t)lv_obj_set_y);
	lv_anim_set_values(&Voltmeter_btn_1_y, lv_obj_get_y(ui->Voltmeter_btn_1), 260);
	_lv_memcpy_small(&Voltmeter_btn_1_y.path, &lv_anim_path_Voltmeter_btn_1, sizeof(lv_anim_path_cb_t));
	lv_anim_start(&Voltmeter_btn_1_y);

	ui->Voltmeter_btn_1_label = lv_label_create(ui->Voltmeter_btn_1, NULL);
	lv_label_set_text(ui->Voltmeter_btn_1_label, "<");
	lv_obj_set_style_local_text_color(ui->Voltmeter_btn_1_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0x00, 0x00, 0x00));
	lv_obj_set_style_local_text_font(ui->Voltmeter_btn_1_label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_simsun_20);

	//Init events for screen
	events_init_Voltmeter(ui);
}